﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace Web.Core
{
    public class Alert
    {
        public static void Message(System.Web.UI.Page page, String val)
        {
            ScriptManager scriptManager = ScriptManager.GetCurrent(page);
            if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), Guid.NewGuid().ToString()))
            {
                if (scriptManager != null && scriptManager.IsInAsyncPostBack)
                    ScriptManager.RegisterStartupScript(page, page.GetType(), Guid.NewGuid().ToString(), String.Format("alert('{0}');", val.Replace("'", "''")), true);
                else
                    page.ClientScript.RegisterStartupScript(page.GetType(), Guid.NewGuid().ToString(), String.Format("alert('{0}');", val.Replace("'", "''")), true);
            }
        }
    }
}